public class ThreadDemo07 {
    public static void main(String[] args) throws InterruptedException {
        Account account = new Account();

        MyThread03 t1 = new MyThread03(account);
        MyThread03 t2 = new MyThread03(account);

        t1.start();
        t2.start();

        t1.join();
        t2.join();

        System.out.println(account.getBalance());

    }
}


class MyThread03 extends Thread {
    private Account account;

    public MyThread03(Account account) {
        this.account = account;
    }

    @Override
    public void run() {
        for (int i = 0; i < 100000; i++) {
            account.add();
        }
    }
}